package com.xbongbong.pro.statistic.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.pro.domain.dao.BiProWareDao;
import com.xbongbong.pro.domain.entity.BiProWareEntity;
import com.xbongbong.pro.statistic.model.BiProWareModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/3/20 10:16
 * @since v1.0
 */
@Service("biProWareModel")
public class BiProWareModelImpl implements BiProWareModel {
    @Resource
    private BiProWareDao dao;
    @Override
    public Integer insert(BiProWareEntity entity){
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return dao.insert(entity);
    }
    @Override
    public Integer update(BiProWareEntity entity){
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return dao.update(entity);
    }

    @Override
    public Integer save(BiProWareEntity entity){
        if(entity.getId() == null || entity.getId().equals(0L)) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public void insertBatch(List<BiProWareEntity> entityList) {
        dao.insertBatch(entityList);
    }

    @Override
    public Integer deleteByKey(Long key, String corpid) {
        return dao.deleteByKey(key , corpid);
    }

    @Override
    public BiProWareEntity getByKey(Long key, String corpid) {
        return dao.getByKey(key , corpid);
    }

    @Override
    public List<BiProWareEntity> findEntitys(Map<String ,Object> param){
        return dao.findEntitys(param);
    }
    @Override
    public Integer getEntitysCount(Map<String ,Object>  param){
        return dao.getEntitysCount(param);
    }
    /**
     * 把所有的isDone都置为0
     * 创建时间： 2018年8月2日 下午8:31:26
     * 修改时间： 2018年8月2日 下午8:31:26 梁鲁江
     * @author 梁鲁江
     * @since
     * @version
     */
    @Override
    public Integer updateIsDoneByKey(Long key, String corpid) {
        return dao.updateIsDoneByKey(key,corpid);
    }

    @Override
    public Integer updateTimeByKey(Long key, String corpid) {
        return dao.updateIsDoneByKey(key,corpid);
    }

    @Override
    public Integer deleteAll(Set<Long> idIn) {
        return dao.deleteAll(idIn);
    }
}
